import React, { Component } from 'react';
import DataSet from '@antv/data-set';
import { Button } from 'antd';

class ChartTransformDemo extends Component {
  state = {
    filterData: { a: 1, b: 2, c: 3 },
  };

  render() {
    const testData1 = [
      {
        date: '2019-11-11',
        counted: '10',
        悲观: 10,
        中立: 20,
        厌恶: 30,
        疑虑: 40,
      },
      {
        date: '2019-11-22',
        counted: '11',
        悲观: 15,
        中立: 25,
        厌恶: 35,
        疑虑: 45,
      },
    ];

    const ds = new DataSet({
      state: {
        currentDate: '2019-11-11',
      },
    });

    const dv = ds.createView().source(testData1);
    // dv.transform({
    //   type: 'filter',
    //   callback(row) {
    //     return row.date === ds.state.currentDate;
    //   },
    // }).transform({
    //   type: 'fold',
    //   fields: ['悲观', '中立', '厌恶', '疑虑'],
    //   key: '情绪类型',
    //   value: '情绪值',
    // });

    dv.transform({
      type:'map',
      callback(row){
        if(row.date===ds.state.currentDate){
          
        }else{
          
        }
      }
    })

    console.log(dv);

    return (
      <div>
        <Button
          onClick={() => {
            ds.setState('currentDate', '2019-11-22');
            console.log(dv);
          }}
        >
          修改状态值
        </Button>
      </div>
    );
  }
}

export default ChartTransformDemo;
